<?php
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     modifier.array_item.php
 * Type:     time
 * Name:     time
 * Author:   王超, <wisoch@hotmail.com>
 * Purpose:  按index取出数组中最小的元素
 * -------------------------------------------------------------
 */
function smarty_modifier_array_item($array, $index, $order = 'min')
{
	$tmp = array();
	foreach ($array as $key => $value) {
		if($tmp) {
			if($value[$index] < $tmp[$index] && $order == 'min') $tmp = $value;
			if($value[$index] > $tmp[$index] && $order == 'max') $tmp = $value;
		} else {
			$tmp = $value;
		}
	}
	return $tmp;
} 
?>